﻿using SQLDataUploadHelper.daos;
using SQLDataUploadHelper.models.domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace SQLDataUploadHelper.services
{
    internal class UploadServerConfigService
    {
        private UploadServerConfigDao uploadServerConfigDao = new UploadServerConfigDao();

        public List<UploadServerConfig> list()
        {
            return uploadServerConfigDao.list();
        }

        public UploadServerConfig getById(long id)
        {
            return uploadServerConfigDao.getById(id);
        }

        public UploadServerConfig add(UploadServerConfig uploadServerConfig)
        {
            return uploadServerConfigDao.add(uploadServerConfig);
        }

        public bool update(UploadServerConfig uploadServerConfig)
        {
            return uploadServerConfigDao.update(uploadServerConfig);
        }

        public UploadServerConfig saveOrUpdate(UploadServerConfig uploadServerConfig)
        {
            if (uploadServerConfig.Id != -1)
            {
                update(uploadServerConfig);
            }
            else
            {
                uploadServerConfig = add(uploadServerConfig);
            }
            return uploadServerConfig;
        }

        public bool delete(long id)
        {
            return uploadServerConfigDao.delete(id);
        }
    }
}
